/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package SysAguas.modelo;

import java.io.Serializable;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Heitor
 */
@Entity
@Table(name="hospede")
public class Hospede implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id; 
    
    @Column(name = "nome", length = 30, nullable = false)
    private String nome;
    
    @Column(name = "sobrenome", length = 100, nullable = false)
    private String sobrenome;
    
    @OneToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "Endereco_id")
    private Endereco enderecoH;
    
    @OneToMany(mappedBy = "hospede", cascade = CascadeType.ALL)
    private List<Telefone> telefones = new LinkedList<Telefone>();
    
    @Temporal(TemporalType.TIMESTAMP)
    private Date dataModificacao;

    @OneToMany(mappedBy="hospedeR",cascade=CascadeType.PERSIST)
    private List<Reserva> reservasH = new LinkedList<Reserva>();

    public Hospede() {
    }

    public List<Reserva> getReservasH() {
        return reservasH;
    }

    public void setReservasH(List<Reserva> reservasH) {
        this.reservasH = reservasH;
    }
    



    public Endereco getEnderecoH() {
        return enderecoH;
    }

    public void setEnderecoH(Endereco enderecoH) {
        this.enderecoH = enderecoH;
    }

    public Date getDataModificacao() {
        return dataModificacao;
    }

    public void setDataModificacao(Date dataModificacao) {
        this.dataModificacao = dataModificacao;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public String getSobrenome() {
        return sobrenome;
    }

    public void setSobrenome(String sobrenome) {
        this.sobrenome = sobrenome;
    }

    public List<Telefone> getTelefones() {
        return telefones;
    }

    public void setTelefones(List<Telefone> telefones) {
        this.telefones = telefones;
    }
    public void addTelefone(Telefone t) {
        
        telefones.add(t);
    }
    public void addReserva(Reserva reserva){
        
        this.reservasH.add(reserva);
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Hospede other = (Hospede) obj;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 53 * hash + (this.id != null ? this.id.hashCode() : 0);
        return hash;
    }


}
